//
//  MyNavgationView.m
//  豆瓣
//
//  Created by Bruce_Lin on 15/4/28.
//  Copyright (c) 2015年 Bruce_Lin. All rights reserved.
//

#import "MyNavgationView.h"

@implementation MyNavgationView

- (void)dealloc
{
    [_right release];
    [_hideView release];
    [_titleName release];
    [_rightImageName release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self creatNavigationView];
    }
    return self;
}

- (void)creatNavigationView
{
    UIImageView *backImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"navi"]];
    backImage.backgroundColor = [UIColor colorWithRed:0.421 green:0.742 blue:0.900 alpha:1.000];
    [backImage setFrame:self.bounds];
    [self addSubview:backImage];
    [backImage release];
}


- (void)creatTitle:(NSString *)titleName
{
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.frame.size.width / 2 - 100, 28, 200, 30)];
    titleLabel.text = titleName;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:titleLabel];
    [titleLabel release];
}


- (void)creatRightButtonWithImage:(NSString *)imageName
{
    self.right = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]];
    [self.right setFrame:CGRectMake(self.frame.size.width - 45, 30, 30, 30)];
    self.right.userInteractionEnabled = YES;
    [self addSubview:self.right];
    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self.rightTarget action:self.rightAction];
    [self.right addGestureRecognizer:tap1];
    
    [tap1 release];
    [self.right release];
    
}

- (void)creatRightButtonToShareOrCollect:(NSString *)imageName gestrue:(UIGestureRecognizer *)gestrue
{
    self.hideView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]];
    [self.hideView setFrame:CGRectMake(self.frame.size.width - 45, 30, 30, 30)];
    self.hideView.userInteractionEnabled = YES;
    [self addSubview:self.hideView];
    
    gestrue = [[UILongPressGestureRecognizer alloc]initWithTarget:self.rightTarget action:self.rightAction];
    [self.hideView addGestureRecognizer:gestrue];

    [_hideView release];
    
}

- (void)creatRightButtonWithLabel:(NSString *)str
{
    UILabel *rightLabel = [[UILabel alloc]init];
    [rightLabel setFrame:CGRectMake(self.frame.size.width - 75, 28, 75, 30)];
    rightLabel.text = str;
    rightLabel.userInteractionEnabled = YES;
    [self addSubview:rightLabel];
    
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc]initWithTarget:self.rightTarget action:self.rightAction];
    [rightLabel addGestureRecognizer:tap2];
    
    [tap2 release];
    [rightLabel release];
    
}

- (void)creatLeftButtonWithImage:(NSString *)imageName
{
    UIImageView *left = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]];
    [left setFrame:CGRectMake(15, 30, 30, 30)];
    left.userInteractionEnabled = YES;
    [self addSubview:left];
    
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initWithTarget:self.leftTarget action:self.leftAction];
    [left addGestureRecognizer:tap3];
    
    [tap3 release];
    [left release];
}

@end
